import { fileURLToPath, URL } from "node:url";

import { defineConfig } from "vite";
import vue from "@vitejs/plugin-vue";
import vueJsx from "@vitejs/plugin-vue-jsx";
import AutoImport from "unplugin-auto-import/vite";
import Components from "unplugin-vue-components/vite";
import { ElementPlusResolver } from "unplugin-vue-components/resolvers";

// https://vitejs.dev/config/
export default defineConfig({
  base:"/metall/",
  esbuild:{
    drop:["console","debugger"],
  },
  plugins: [
    vue(),
    vueJsx(),
    AutoImport({
      resolvers: [ElementPlusResolver()],
    }),
    Components({
      resolvers: [ElementPlusResolver()],
    }),
  ],
  resolve: {
    alias: {
      "@": fileURLToPath(new URL("./src", import.meta.url)),
      "#": fileURLToPath(new URL("./types", import.meta.url)),
    },
  },
  server: {
    proxy: {
      "/m.api": {
        target: "http://192.168.1.188:8080", //接口地址
        changeOrigin: true,
      },
      "/upload/admin": {
        target: "http://192.168.1.188:8080", // 后台接口地址
        ws: true, //如果要代理 websockets，配置这个参
        changeOrigin: true, //是否跨域
      },
    },
  },
});
